<template>
  <!-- 配件替换件及库存信息 -->
  <div class="wrap">
    <el-form :model="formData">
      <el-form-item label="经销商级别目标服务水平：" :label-width="labelWidth">
        <el-form-item label="" :label-width="labelWidthCol">
          <el-radio-group v-model="dZTSL" @change="clickHandleDealer">
            <el-radio label="H">高</el-radio>
            <el-radio label="M">中</el-radio>
            <el-radio label="L">低</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form-item>
      <el-form-item label="配件级别目标服务水平：" :label-width="labelWidth">
        <el-form-item label="A类" :label-width="labelWidthCol">
          <el-radio-group v-model="aZTSL" @change="clickHandle">
            <el-radio label="H">高</el-radio>
            <el-radio label="M">中</el-radio>
            <el-radio label="L">低</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="B类" :label-width="labelWidthCol">
          <el-radio-group v-model="bZTSL" @change="clickHandle">
            <el-radio label="H">高</el-radio>
            <el-radio label="M">中</el-radio>
            <el-radio label="L">低</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="C类" :label-width="labelWidthCol">
          <el-radio-group v-model="cZTSL" @change="clickHandle">
            <el-radio label="H">高</el-radio>
            <el-radio label="M">中</el-radio>
            <el-radio label="L">低</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form-item>
      <el-form-item label="" :label-width="labelWidth">
        <el-form-item label=""><AjaxButton :click="saveHandle" type="primary">保存</AjaxButton> </el-form-item>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { uploadSericeLevel } from '@/api/part/report/tslServiceLevel';
class ServiceLevel {
  constructor(ZABC, ZTSL) {
    this.ZTSL = ZTSL;
    this.ZABC = ZABC;
  }
}
export default {
  name: 'ServiceLevel',
  components: {},
  mixins: [dictionary],
  props: [],
  data() {
    return {
      labelWidth: '200px',
      labelWidthCol: '40px',
      radio1: '1',
      dealerServiceLevel: new ServiceLevel(''),
      aServiceLevel: new ServiceLevel('A', ''),
      bServiceLevel: new ServiceLevel('B', ''),
      cServiceLevel: new ServiceLevel('C', ''),
      dZTSL: 'M',
      aZTSL: 'M',
      bZTSL: 'M',
      cZTSL: 'M',
      formInline: {
        user: '',
        region: ''
      },
      tableData: [],
      formData: {}
    };
  },
  watch: {
    dZTSL(newVal, oldVal) {
      this.dealerServiceLevel.ZTSL = newVal;
    },
    aZTSL(newVal, oldVal) {
      this.aServiceLevel.ZTSL = newVal;
    },
    bZTSL(newVal, oldVal) {
      this.bServiceLevel.ZTSL = newVal;
    },
    cZTSL(newVal, oldVal) {
      this.cServiceLevel.ZTSL = newVal;
    }
  },
  methods: {
    // 点击事件
    clickHandleDealer(val) {},
    // 点击事件
    clickHandle(val) {
      let tempData = Object.assign({ dealerLevel: val });
    },

    async onSubmit(val) {
      let res = await uploadSericeLevel(val);
      if (res.resultCode == 200) {
        if (res.data) {
          return this.$notify.success({ title: '提示信息', message: '上传成功' });
        }
        return this.$notify.error({ title: '提示信息', message: '上传失败' });
      }
    },
    // 保存
    saveHandle() {
      this.tableData = [];
      if (this.dealerServiceLevel != null) {
        this.tableData.push(this.dealerServiceLevel);
      }
      this.tableData.push(this.aServiceLevel, this.bServiceLevel, this.cServiceLevel);
      // this.formData.epr3sps092ItTlsModels = this.tableData;
      this.onSubmit(this.tableData);
    }
  }
};
</script>

<style scoped>
.wrap {
  margin-top: 15px;
  padding-top: 15px;
}
</style>
